<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<title>完善资料</title>
<script type="text/javascript" src="__PUBLIC__/index/js/jquery-1.8.1.js"></script>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<link href="__PUBLIC__/index/css/phone.css" type="text/css" rel="stylesheet">
<link href="__PUBLIC__/index/css/css.css" type="text/css" rel="stylesheet">

<script type="text/javascript" src="__PUBLIC__/index/js/alert.js"></script>
</head>

<body>
  <div class="pact">
            <form  method="post" action="{:U('Gj/phone_up')}" id="register">
            <ul>
                <p id="err_msg"></p> 
                
                <li><i class="un"></i><input class="username"  id="verify_btn" type="text"  value="{$list.phone}" /><a><img src="__PUBLIC__/index/image/phone/chah1.png" class="cha"></a></li>
                 <li><i class="yz"></i><input class="yzm" type="text" id="verify" placeholder="请输入验证码" /><input type="button" id="send" value="发送验证码" /></li>
                  <!-- 表单令牌验证 begin-->
                  <input type="hidden" value="{$arr}" id="token" name="token">
                  <!-- 表单令牌验证 end-->
             
            </ul>
                <div class="reg_btn">
                    <button class="submit" type="button" onClick="checksubmit();">确认修改</button>
                </div>
            </form>
        </div>
</body>
</html>
<script type="text/javascript">
// 去除微信右上角的点点点
wx.config({
    debug: false,
    appId: "{$sign.appid}",
    timestamp:"{$sign.timestamp}",
    nonceStr:"{$sign.noncestr}",
    signature:"{$sign.signature}",
    jsApiList: [
        'wx.hideOptionMenu',
      ]
});
wx.checkJsApi({
    jsApiList: [
        'getLocation'
    ],
    success: function (res) {
  
        if (res.checkResult.getLocation == false) {
            alert('你的微信版本太低，不支持微信JS接口，请升级到最新的微信版本！');
            return;
        }
    }
});
//隐藏微信右上角
wx.ready(function () {
   wx.hideOptionMenu();
    
});
  
  function checksubmit(){
    var phone = $('#verify_btn').val();
    var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
       if(!reg.test(phone)) 
          { 
            hint('请输入有效的手机号码!');
             return false; 
         }

    var v=$("#verify").val();
    if (phone=="" || v=="") {
      hint("手机号或者验证码不能为空");
      return false;
    };
    var data={
      phone:phone,
      num:v,
    }
    $.post('{:U("Forget/check")}',data,function(obj){
      if (obj.c=="openid") {
      hint(obj.m);
      return false;
      };
      if (obj.c=="shixiao") {
        hint(obj.m);
        return false;
      };
      if (obj.c=="error") {
        hint(obj.m);
        return false;
      };
      if (obj.c=="yes") {
        $("#register").submit();
      };
    });
  }

  var wait=60;  
  function time(o) {  
          if (wait == 0) {  
              o.removeAttribute("disabled");            
              o.value="获取验证码";  
              wait = 60;  
          } else {  
              o.setAttribute("disabled", true);  
              o.value="重新发送(" + wait + ")";  
              wait--;  
              setTimeout(function() {  
                  time(o)  
              },  
              1000)  
          }  
      }  
  document.getElementById("send").onclick=function(){
    var phone=$('#verify_btn').val();
    var token=$('#token').val();
    var data={
      phone:phone,
      token:token,
      }
      var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
       if(!reg.test(phone)) 
          { 
             hint('请输入有效的手机号码!'); 
         
             return false; 
         }else{
        $.post('{:U("Gj/msg")}',data,function(obj){
          if (obj.s=="no") {
            hint(obj.m);
          };
          if (obj.s=="ok") {
            hint(obj.m);
          };
          if (obj.s=="check") {
          hint(obj.m);
          };
          if (obj.s=="fail") {
            hint(obj.m);
          };
          });
      }

      time(this);

  } 

  $(".cha").click(function() {
    $("#verify_btn").attr("value","");
  });

</script>

